package com.wxy.test2.proxypattern;

import java.text.SimpleDateFormat;
import java.util.Date;

public class ProxyLog implements AbstractLog{
    private RealLog realLog;

    public ProxyLog(RealLog realLog) {
        this.realLog = realLog;
    }

    @Override
    public void method() {
        Date date = new Date();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("方法method()被调用，调用时间为" + format.format(date));
        try {
            realLog.method();
            System.out.println("方法method()调用成功");
        }catch (Exception e){
            System.out.println("方法method()调用失败");
        }
    }
}
